<!DOCTYPE html>
<#assign ctxPath = request.contextPath />
<html>
<head>
    <title>登录</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${ctxPath}/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/css/login.css" media="all">
    <style>
        body {
            background-position: center 110px;
            background-repeat: no-repeat;
            background-size: 100%;
            background-color: #f0f2f5;
        }

        .login-header {
            color: rgba(0, 0, 0, .85) !important;
        }

        .login-footer {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a:hover {
            color: rgba(0, 0, 0, 0.4) !important;
        }
    </style>
</head>

<body>
<div class="login-wrapper">

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;用户登录
            </div>
            <form class="layui-card-body layui-form layui-form-pane">
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-block">
                        <input name="userName" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input name="passWord" type="password" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <a href="/reg" class="layui-link">帐号注册</a>
                </div>
                <div class="layui-form-item">
                    <button lay-filter="login-submit" class="layui-btn layui-btn-fluid" lay-submit>登 录</button>
                </div>
            </form>
        </div>
    </div>

    <div class="login-footer">
    </div>
</div>

<script type="text/javascript" src="layui/layui.js"></script>
<!--<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js"></script>-->

<script>
    layui.use(['layer', 'form'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        // 表单提交
        form.on('submit(login-submit)', function (obj) {
            var field = obj.field;
            //请求接口
            $.post(
                '/users/login'
                , {
                    userName: field.userName,
                    passWord: field.passWord
                }
                , function (res) {
                    if (res.success == true) {
                        window.location.href = '${ctxPath}/success'
                    } else {
                        layer.msg(res.message)
                        // window.location.href='/'
                    }
                }
            );

            return false;

        });


    });
</script>


</body>
</html>
